<template>
	<view class="content">
		<!-- <view class="title tr">《家味用户协议》</view> -->
		<u-parse :content="data"></u-parse>
	</view>
</template>

<script>
	import {
		getAgreementApi
	} from '@/api/user'
	import Cache from '@/util/cache.js'
	export default {
		data() {
			return {
				data: '',
				type: '', //4.服务协议 5.用户协议 6.隐私协议 7.拼团规则
			}
		},
		onLoad(options) {
			if (options.type) {
				this.type = options.type
				if (this.type == 3) {
					uni.setNavigationBarTitle({
						title: '关于我们'
					})
					this.getService('about')
				} else if (this.type == 4) {
					uni.setNavigationBarTitle({
						title: '服务协议'
					})
					this.getService('user_service')
					// this.getfuwu();
				} else if (this.type == 5) {
					uni.setNavigationBarTitle({
						title: '用户协议'
					})
					// this.getyonghu();
					this.getService('sys_user_agree')
				} else if (this.type == 6) {
					uni.setNavigationBarTitle({
						title: '隐私协议'
					})
					// this.getyinsi();
					this.getService('user_privacy')
				} else if (this.type == 7) {
					uni.setNavigationBarTitle({
						title: '拼团规则'
					})
					// this.getyinsi();
					this.getService('group_buying_rule')
				} else if (this.type == 9) {
					uni.setNavigationBarTitle({
						title: '使用说明'
					})
					this.getService('card_instructions')
				} else if (this.type == 10) {
					uni.setNavigationBarTitle({
						title: '满汉全席活动规则'
					})
					this.getmhrule()
				} else if (this.type == 11) {
					uni.setNavigationBarTitle({
						title: '美食官规则'
					})
					// this.fenxiaoxieyi()
					this.getService('sys_brokerage')
				}else if (this.type == 12) {
					uni.setNavigationBarTitle({
						title: '活动规则'
					})
					// this.fenxiaoxieyi()
					this.getService('sys_extension_agree')
				}
			}
			// this.getData()
		},
		methods: {
			getService(type) {
				let str = Cache.get(type)
				if (str) {
					this.data = str
				} else {
					getAgreementApi(type).then(res => {
						this.data = res.data.result
						Cache.set(type, res.data.result, 60)
					}).catch(err => {

					})
				}
			},
			// 满汉全席
			getmhrule(){
				this.$request("user/banquet/lst",{},'GET').then(res=>{
					this.data=res.data.target.rule
				})
			},
			// 服务协议
			// getfuwu() {
			// 	this.$request('agreement/user_service', {}, 'GET').then(res => {
			// 		console.log(res);
			// 		this.data = res.data.result;
			// 	})
			// },
			// // 隐私协议
			// getyinsi() {
			// 	this.$request('agreement/user_privacy', {}, 'GET').then(res => {
			// 		console.log(res);
			// 		this.data = res.data.result;
			// 	})
			// },
			// // yonghu协议
			// getyonghu() {
			// 	this.$request('agreement/sys_user_agree ', {}, 'GET').then(res => {
			// 		console.log(res);
			// 		this.data = res.data.result;
			// 	})
			// },
			// //
			// // 
			// getData() {
			// 	this.$request('agreement/sys_user_agree', {}, 'GET').then(res => {

			// 		// this.data=res.data.data.user_agreement;

			// 		console.log(res);
			// 	})
			// },
			// // 分销协议
			// fenxiaoxieyi() {
			// 	this.$request('cache/sys_brokerage', {}, 'GET').then(res => {
			// 		console.log(res);
			// 		this.data = res.data.sys_brokerage;
			// 	})
			// },

		}
	}
</script>

<style scoped>


	.content {
		padding: 20rpx;
		box-sizing: border-box;
	}
</style>
